﻿<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
  </head>
  <body>
        <div style="right:0;position:absolute;"><a href="./home"><img style="width:40px;height:40px;" src="img/home.png" alt="返回主页" /></a></div>
    <h1><%= title %></h1>
    <form action="./changePassword" method="post">
        账号：<input id='userName'type="text" placeholder="请输入账号" name="userName"/><br/>
        邮箱验证码：<input type="text" placeholder="请输入邮箱验证码" name="emailCode"/><button onclick='aa(event);' id="pp">获取邮箱验证码</button><br/>
        输入新密码：<input type="password" placeholder="请输入新密码" name="passWord1"/><br/>
        确认新密码：<input type="password" placeholder="请确认新密码" name="passWord2"/><br/>
        <input type="submit" value="确认修改" /><br/> 
    </form>
	<script>
		function aa(event) {
            //邮箱发送间隔
            var node = document.getElementById("pp");
            node.setAttribute("disabled", true);
            var count = 60;
            var timer = setInterval(function(){
                node.innerHTML = count+"秒后重发";
                //node.onclick = null;
                count--;
                if(count == -1) {
                    clearInterval(timer);
                    node.innerHTML = "获取邮箱验证码";
                    node.removeAttribute("disabled");
                    //node.onclick = aa;
                }
            }, 1000); 
			event.preventDefault();
			event.stopPropagation();
			var user = document.getElementById('userName').value;
			console.log(user);
			//对temEmail编码
			var userName = encodeURIComponent(user);
			console.log(userName);
			//发送ajax请求
			var xhr;
			if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
				xhr=new XMLHttpRequest();
			}
			else {// code for IE6, IE5
				xhr=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xhr.onreadystatechange=function() {
				if (xhr.readyState==4 && xhr.status==200) {
					console.log('发送完成');
				}
			}
			xhr.open("POST","./sendEmailCodeForChangePWD",true);
			xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			xhr.send("userName="+userName);
		}		
	</script>
  </body>
</html>
